package br.com.ovopoche.model.to;

import java.io.Serializable;
import java.util.Collection;
import java.util.PriorityQueue;

/**
 * Represents a movie and provides access to its title, rating, subtitles and
 * timetables.
 * 
 * @author rafael
 * 
 */
public class MovieTO implements Serializable {

	/**
	 * The serial version UID.
	 */
	private static final long serialVersionUID = -2917403035378298555L;

	/** The title. **/
	private String title;

	/** The rating information. **/
	private String rating;

	/** The information about language, subtitles and dubbing. **/
	private String language;

	/** The duration. **/
	private String duration;

	/** The genre. **/
	private String genre;

	/** The timetables. **/
	private Collection<String> timetables;

	/**
	 * Adds a timetable to the current movie.
	 * 
	 * @param timetable
	 *            the timetable to be added.
	 */
	public void addTimetable(String timetable) {

		// Initialize the timetables if they are null
		if (timetables == null) {
			timetables = new PriorityQueue<String>();
		}

		timetables.add(timetable);
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return the rating
	 */
	public String getRating() {
		return rating;
	}

	/**
	 * @param rating
	 *            the rating to set
	 */
	public void setRating(String rating) {
		this.rating = rating;
	}

	/**
	 * @return the timetables
	 */
	public Collection<String> getTimetables() {
		return timetables;
	}

	/**
	 * @param timetables
	 *            the timetables to set
	 */
	public void setTimetables(Collection<String> timetables) {
		this.timetables = timetables;
	}

	/**
	 * @return the language
	 */
	public String getLanguage() {
		return language;
	}

	/**
	 * @param language
	 *            the language to set
	 */
	public void setLanguage(String language) {
		this.language = language;
	}

	/**
	 * @return the duration
	 */
	public String getDuration() {
		return duration;
	}

	/**
	 * @param duration
	 *            the duration to set
	 */
	public void setDuration(String duration) {
		this.duration = duration;
	}

	/**
	 * @return the genre
	 */
	public String getGenre() {
		return genre;
	}

	/**
	 * @param genre
	 *            the genre to set
	 */
	public void setGenre(String genre) {
		this.genre = genre;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "MovieTO [title=" + title + ", rating=" + rating + ", language="
				+ language + ", duration=" + duration + ", genre=" + genre
				+ ", timetables=" + timetables + "]";
	}

}
